package com.project.controller;


import com.project.bean.SendInfoBean;
import com.project.service.ISendInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 收货信息表（用户模块） 前端控制器
 * </p>
 *
 * @author lhy
 * @since 2021-10-05
 */
@RestController
@RequestMapping("/sendInfo")
@Api(tags = "收货信息测试接口")
public class SendInfoController extends ApiBaseController {
    @Autowired
    private ISendInfoService sendInfoService;

    @GetMapping("/addSendInfo")
    @ApiOperation(value = "添加收货信息")
    public boolean addSendInfo(SendInfoBean sendInfoBean) {
        sendInfoService.addSendInfo(sendInfoBean);
        return true;
    }

    @GetMapping("/updateSendInfo")
    @ApiOperation(value = "修改用户收货地址")
    public boolean updateSendInfo(Integer sendInfoId, String newAddress, String newReceiver, String newGentle, String newPhone) {
        sendInfoService.updateSendInfo(sendInfoId, newAddress, newReceiver, newGentle, newPhone);
        return true;
    }

    @GetMapping("/defaultSendInfo")
    @ApiOperation(value = "修改默认收货信息id")
    public Integer defaultSendInfo(Integer defaultSendInfoId, Integer userId) {
        sendInfoService.defaultSendInfo(defaultSendInfoId, userId);
        return defaultSendInfoId;
    }

    @GetMapping("/findByUserId")
    @ApiOperation(value = "查询登录用户所有收获信息")
    public String findByUserId(int userId) {
        return String.valueOf(sendInfoService.findByUserId(userId));

    }
}
